home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / emacs / emacs1857 / src_d2.zoo / source / lisp.h < prev    next >
C/C++ Source or Header  |  1991-12-02  |  34KB  |  994 lines

  1. /* Fundamental definitions for GNU Emacs Lisp interpreter.
  2.    Copyright (C) 1985, 1986, 1987 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU Emacs.
  5.  
  6. GNU Emacs is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GNU Emacs is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU Emacs; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. /* Define the fundamental Lisp data structures */
  22.  
  23. /* This is the set of Lisp data types */
  24.  
  25. enum Lisp_Type
  26.   {
  27.     /* Integer.  object.v.integer is the integer value. */
  28.     Lisp_Int,
  29.  
  30.     /* Symbol.  object.v.symbol points to a struct Lisp_Symbol. */
  31.     Lisp_Symbol,
  32.  
  33.     /* Marker (editor pointer).  object.v.marker points to a struct Lisp_Marker. */
  34.     Lisp_Marker,
  35.  
  36.     /* String.  object.v.string points to a struct Lisp_String.
  37.        The length of the string, and its contents, are stored therein. */
  38.     Lisp_String,
  39.  
  40.     /* Vector of Lisp objects.  object.v.vector points to a struct Lisp_Vector.
  41.        The length of the vector, and its contents, are stored therein. */
  42.     Lisp_Vector,
  43.  
  44.     /* Cons.  object.v.cons points to a struct Lisp_Cons. */
  45.     Lisp_Cons,
  46.  
  47.     /* >>> No longer used */
  48.     Lisp_Object_Unused_1,
  49. #if 0
  50.     was...
  51.     /* Treated like vector in GC, except do not set its mark bit.
  52.        Used for internal data blocks that will be explicitly freed
  53.        but which, while active, are reached by GC mark exactly once
  54.        and should be marked through like a vector.  */
  55.     Lisp_Temp_Vector,
  56. #endif 0
  57.  
  58.     /* Editor buffer.  obj.v.buffer points to a struct buffer.
  59.        No buffer is ever truly freed; they can be "killed", but this
  60.        just marks them as dead. */
  61.     Lisp_Buffer,
  62.  
  63.     /* Built-in function.  obj.v.subr points to a struct Lisp_Subr
  64.        which describes how to call the function, and its documentation,
  65.        as well as pointing to the code. */
  66.     Lisp_Subr,
  67.  
  68.     /* Internal value return by subroutines of read.
  69.        The user never sees this data type.
  70.        Its value is just a number. */
  71.     Lisp_Internal,
  72.  
  73.     /* Forwarding pointer to an int variable.
  74.        This is allowed only in the value cell of a symbol,
  75.        and it means that the symbol's value really lives in the
  76.        specified int variable.
  77.        obj.v.intptr points to the int variable. */
  78.     Lisp_Intfwd,
  79.  
  80.     /* Boolean forwarding pointer to an int variable.
  81.        This is like Lisp_Intfwd except that the ostensible "value" of the symbol
  82.        is t if the int variable is nonzero, nil if it is zero.
  83.        obj.v.intptr points to the int variable. */
  84.     Lisp_Boolfwd,
  85.  
  86.     /* Object describing a connection to a subprocess.
  87.        It points to storage of type  struct Lisp_Process  */
  88.     Lisp_Process,
  89.  
  90.     /* Forwarding pointer to a Lisp_Object variable.
  91.        This is allowed only in the value cell of a symbol,
  92.        and it means that the symbol's value really lives in the
  93.        specified variable.
  94.        obj.v.objfwd points to the Lisp_Object variable. */
  95.     Lisp_Objfwd,
  96.  
  97.       /* was Lisp_Internal */
  98.     Lisp_Object_Unused_2,
  99.  
  100.     /* Used when a FILE * value needs to be passed
  101.        in an argument of type Lisp_Object.
  102.        You must do (FILE *) obj.v.integer to get the value.
  103.        The user will never see this data type. */
  104.     Lisp_Internal_Stream,
  105.  
  106.     /* Used in a symbol value cell when the symbol's value is per-buffer.
  107.         The actual contents are a cons cell which starts a list like this:
  108.         (REALVALUE BUFFER CURRENT-ALIST-ELEMENT . DEFAULT-VALUE)).
  109.  
  110.     BUFFER is the last buffer for which this symbol's value was
  111.     made up to date.
  112.  
  113.         CURRENT-ALIST-ELEMENT is a pointer to an element of BUFFER's
  114.     b_local_var_alist, that being the element whose car is this variable.
  115.         Or it can be a pointer to the (CURRENT-ALIST-ELEMENT . DEFAULT-VALUE), if BUFFER
  116.     does not have an element in its alist for this variable
  117.     (that is, if BUFFER sees the default value of this variable).
  118.  
  119.     If we want to examine or set the value and BUFFER is current,
  120.     we just examine or set REALVALUE.
  121.     If BUFFER is not current, we store the current REALVALUE value into
  122.     CURRENT-ALIST-ELEMENT, then find the appropriate alist element for
  123.     the buffer now current and set up CURRENT-ALIST-ELEMENT.
  124.     Then we set REALVALUE out of that element, and store into BUFFER.
  125.  
  126.     If we are setting the variable and the current buffer does not have
  127.     an alist entry for this variable, an alist entry is created.
  128.  
  129.     Note that REALVALUE can be a forwarding pointer.
  130.     Each time it is examined or set, forwarding must be done.  */
  131.     Lisp_Buffer_Local_Value,
  132.  
  133.     /* Like Lisp_Buffer_Local_Value with one difference:
  134.     merely setting the variable while some buffer is current
  135.     does not cause that buffer to have its own local value of this variable.
  136.     Only make-local-variable does that.  */
  137.     Lisp_Some_Buffer_Local_Value,
  138.  
  139.  
  140.     /* Like Lisp_Objfwd except that value lives in a slot
  141.        in the current buffer.  Value is byte index of slot within buffer */
  142.     Lisp_Buffer_Objfwd,
  143.  
  144.     /* In symbol value cell, means var is unbound.
  145.        In symbol function cell, means function name is undefined. */
  146.     Lisp_Void,
  147.  
  148.     /* Window used for Emacs display.
  149.        Data inside looks like a Lisp_Vector.  */
  150.     Lisp_Window,
  151.  
  152.     /* Used by save,set,restore-window-configuration */
  153.     Lisp_Window_Configuration
  154.   };
  155.  
  156. #ifndef NO_UNION_TYPE
  157.  
  158. #ifndef BIG_ENDIAN
  159.  
  160. /* Definition of Lisp_Object for little-endian machines.  */
  161.  
  162. typedef
  163. union Lisp_Object
  164.   {
  165.     /* Used for comparing two Lisp_Objects;
  166.        also, positive integers can be accessed fast this way. */
  167.     int i;
  168.  
  169.     struct
  170.       {
  171.     int val: 24;
  172.     char type;
  173.       } s;
  174.     struct
  175.       {
  176.     unsigned int val: 24;
  177.     char type;
  178.       } u;
  179.     struct
  180.       {
  181.     unsigned int val: 24;
  182.     enum Lisp_Type type: 7;
  183.     /* The markbit is not really part of the value of a Lisp_Object,
  184.        and is always zero except during garbage collection.  */
  185.     unsigned int markbit: 1;
  186.       } gu;
  187.   }
  188. Lisp_Object;
  189.  
  190. #else /* If BIG_ENDIAN */
  191.  
  192. typedef
  193. union Lisp_Object
  194.   {
  195.     /* Used for comparing two Lisp_Objects;
  196.        also, positive integers can be accessed fast this way. */
  197.     int i;
  198.  
  199.     struct
  200.       {
  201.     char type;
  202.     int val: 24;
  203.       } s;
  204.     struct
  205.       {
  206.     char type;
  207.     unsigned int val: 24;
  208.       } u;
  209.     struct
  210.       {
  211.     /* The markbit is not really part of the value of a Lisp_Object,
  212.        and is always zero except during garbage collection.  */
  213.     unsigned int markbit: 1;
  214.     enum Lisp_Type type: 7;
  215.     unsigned int val: 24;
  216.       } gu;
  217.   }
  218. Lisp_Object;
  219.  
  220. #endif BIG_ENDIAN
  221.  
  222. #endif NO_UNION_TYPE
  223.  
  224.  
  225. /* If union type is not wanted, define Lisp_Object as just a number
  226.    and define the macros below to extract fields by shifting */
  227.  
  228. #ifdef NO_UNION_TYPE
  229.  
  230. #define Lisp_Object int
  231.  
  232. /* These values are overridden by the m- file on some machines.  */
  233. #ifndef VALBITS
  234. #define VALBITS 24
  235. #endif
  236.  
  237. #ifndef GCTYPEBITS
  238. #define GCTYPEBITS 7
  239. #endif
  240.  
  241. #ifndef VALMASK
  242. #define VALMASK ((1<<VALBITS) - 1)
  243. #endif
  244. #define GCTYPEMASK ((1<<GCTYPEBITS) - 1)
  245. #define MARKBIT (1 << (VALBITS + GCTYPEBITS))
  246.  
  247. #endif /* NO_UNION_TYPE */
  248.  
  249. /* These macros extract various sorts of values from a Lisp_Object.
  250.  For example, if tem is a Lisp_Object whose type is Lisp_Cons,
  251.  XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */
  252.  
  253. #ifdef NO_UNION_TYPE
  254.  
  255. /* One need to override this if there must be high bits set in data space
  256.    (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work
  257.     on all machines, but would penalise machines which don't need it)
  258.  */
  259. #ifndef XTYPE
  260. #define XTYPE(a) ((enum Lisp_Type) ((a) >> VALBITS))
  261. #endif
  262.  
  263. #ifndef XSETTYPE
  264. #define XSETTYPE(a, b) ((a)  =  XUINT (a) | ((int)(b) << VALBITS))
  265. #endif
  266.  
  267. /* Use XFASTINT for fast retrieval and storage of integers known
  268.